<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>角色列表</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="/shop/static/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="/shop/static/css/public.css" media="all" type="text/css">
</head>
<body class="childrenBody">
<form class="layui-form" lay-filter="example">
	<blockquote class="layui-elem-quote quoteBox">
			<div class="layui-inline">
				<a class="layui-btn layui-btn-normal addRole">添加角色</a>
			</div>
<!-- 			<div class="layui-inline">
				<a class="layui-btn layui-btn-danger layui-btn-normal delAll_btn">批量删除</a>
			</div> -->
	</blockquote>
	<table id="productsList" lay-filter="productsList"></table>
</form>
	<!--审核状态-->
	<script type="text/html" id="productsStatus">
		
		<span class="layui-red">{{d.productName}}</span>

	</script>

	<!--操作-->
	<script type="text/html" id="roleListBar">
		<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
		<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
	</script>
<script src="/shop/static/layui/layui.js" charset="utf-8" type="text/javascript"></script>
<script type="text/javascript" src="/shop/static/js/common/jquery-2.1.0.min.js"></script>
<script type="text/javascript">
layui.use(['form','layer','laydate','table','laytpl'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery,
        laydate = layui.laydate,
        laytpl = layui.laytpl,
        table = layui.table;

    //列表
    var tableIns = table.render({
        elem: '#productsList',
        url : '/shop/power/queryRolePage',
        cellMinWidth : 95,
        page : true,
        height : "full-125",
        limit : 20,
        limits : [1,10,15,20,25],
        id : "productsListTable",
        cols : [[
            {type: "checkbox", fixed:"left", width:50},
            {field: 'roleName', title: '角色名称'},
            {field: 'roleSynopsis', title: '角色描述'},
            {title: '操作', width:170, templet:'#roleListBar',fixed:"right",align:"center"}
        ]]
    ,skin: 'line'
    });

    //编辑商品
    function editproducts(edit){
    	   window.location.href="/shop/power/addRole?id="+edit.id;
    }
    $(".addRole").click(function(){
    	window.location.href="/shop/power/addRole"; 
    })

    //列表操作
    table.on('tool(productsList)', function(obj){
        var layEvent = obj.event,
            data = obj.data;

        if(layEvent === 'edit'){ //编辑
            editproducts(data);
        } else if(layEvent === 'del'){ //删除
            layer.confirm('确定删除此角色？',{icon:3, title:'提示信息'},function(index){
                 $.get("/shop/power/deleteRole",{
                     id : data.id  //将需要删除的productsId作为参数传入
                 },function(data){
                    tableIns.reload();
                    layer.close(index);
                 })
            });
        } 
    });

})
</script>
</body>
</html>